document.getElementById("name").addEventListener("blur",function(){

	if(this.value == "")
	{
		document.querySelectorAll(".nameerror")[0].innerHTML = "分类名称不能为空";
		return ;
	}
	var xhr = new XMLHttpRequest();
	xhr.responseType = "json";

	xhr.open("get","/Manager/Category/getCategoryByName.html?name="+this.value,true);

	xhr.onload = function(){
		if(xhr.status == 200)
		{
			var res = xhr.response;
			if(parseInt(res.code) == 0)
			{
				state = 0;
				document.querySelectorAll(".nameerror")[0].innerHTML = res.message;
			}
			else
			{
				state = 1;
				document.querySelectorAll(".nameerror")[0].innerHTML = "";
			}
		}
	}
	xhr.send();
});
var state = 0;
function myConfirm()
{
	if(document.getElementById("name").value == "")
	{
		document.querySelectorAll(".nameerror")[0].innerHTML = "分类名称不能为空";
		return false;
	}
	if(state == 0)
	{
		return false;
	}
	return confirm("确认添加分类?");
}